<template>
	<view class="recruitment-agent">
		<NavBar title="代理商招募" color="#fff" bgc="transparent" />
		<view class="content">
			<view class="agent-desc">
				<view class="item">
					<view class="title"> 招商政策 </view>
					<view class="text"> 此处是招商政策说明；此处是招商政策说明，此处是招商政策说明，此处是招商政策说明此处是招商政策说明此处是招商政策说明 </view>
				</view>
				<view class="item">
					<view class="title"> 入驻流程 </view>
					<view class="text"> 此处是招商政策说明；此处是招商政策说明，此处是招商政策说明，此处是招商政策说明此处是招商政策说明此处是招商政策说明 </view>
				</view>
				<view class="item">
					<view class="title"> 代理商奖励机制 </view>
					<view class="text"> 此处说明成为代理商能够在平台中获取的利润解释 </view>
				</view>
			</view>
		</view>
		<view class="btn-box">
			<view class="btn" @tap="signUpNow"> 立即报名 </view>
		</view>
	</view>
</template>

<script setup>
	import { onLoad } from '@dcloudio/uni-app'
	import { useUserStore } from '@/store/index.js'
	import { GetBecomeAgentApi } from '@/service/index.js'
	import NavBar from '@/components/NavBar.vue';
	const signUpNow = () => {
		uni.redirectTo({
			url: '/pages/agentPages/becomeAgent/becomeAgent'
		})
	}
	const isAgent = () => {
		const { GETUSERINFO } = useUserStore()
		//  id 为空时表示没有申请
		// status 0=待审核 1=审核通过 2=审核驳回
		GetBecomeAgentApi().then(res => {
			if (res.id) {
				let navParams = {}
				let title = ''
				if (res.status == 0) {
					title = '报名成功'
					navParams = {
						title: '提交成功',
						tips: '您的代理商申请资料提交成功请耐心等待平台审核！',
					}
					uni.redirectTo({
						url: `/pages/auditStatus/auditStatus?title=${title}&params=${JSON.stringify(navParams)}`
					})
				} else if (res.status == 1) {
					GETUSERINFO()
					uni.redirectTo({ url: '/pages/agentPages/agentHome/agentHome' })
				} else {
					title = '审核未通过'
					navParams = {
						tips: '您可能信息提交有误，可以编辑信息后继续提交审核！',
						imgType: 'error',
						errText: res.reject_msg,
						cancelText: '返回首页',
						submitText: '编辑信息'
					}
					uni.redirectTo({
						url: `/pages/auditStatus/auditStatus?title=${title}&params=${JSON.stringify(navParams)}`
					})
				}
			}
		})
	}
	onLoad(() => {
		isAgent()
	})
</script>

<style scoped lang="scss">
	.recruitment-agent {
		width: 100%;
		background: url('/static/icon/agent/agent_bg.png') no-repeat center center;
		background-size: 100% auto;
		background-position: 0 0;
		.content {
			margin-top: 150px;
			padding: 10px 12px 70px;
			.agent-desc {
				padding: 22px 20px;
				border-radius: 10px;
				background-color: #fff;
			}
			.item {
				margin-top: 30px;
				&:nth-of-type(1) {
					margin-top: 0;
				}
				.title {
					color: #333333;
					font-size: 16px;
					font-weight: 500;
					line-height: 19px;
					margin-bottom: 10px;
				}
				.text {
					color: #999999;
					font-size: 14px;
					font-weight: 400;
					line-height: 18px;
				}
			}
		}
		.btn-box {
			position: fixed;
			left: 0;
			right: 0;
			bottom: 0;
			background: #F4F5F7;
			padding: 0 12px 10px;
			.btn {
				height: 50px;
				color: #FFFFFF;
				font-size: 17px;
				font-weight: 500;
				display: flex;
				align-items: center;
				justify-content: center;
				background: #FF3B1E;
				border-radius: 106px;
			}
		}
	}
</style>
